import Vue from 'vue'
import VueRouter from 'vue-router'

//页面级组件
import Layout from '@/components/Layout.vue'

Vue.use(VueRouter)

const routes = [{
		alias: '/', //别名
		path: '/login',
		name: 'Login',
		meta: { requiresAuth: false },
		component: () => import('@/views/Admin/Login.vue')
	},
	{
		path: '/register',
		name: 'Register',
		meta: { requiresAuth: false },
		component: () => import('@/views/Admin/Register.vue')
	},
	{
		path: '/goods/',
		name: 'Goods',
		component: Layout,
		meta: { requiresAuth: true },
		children: [{
				path: 'list',
				name: 'GoodsList',
				component: () => import('@/views/Goods/List.vue')
			},
			{
				path: 'edit/:id',
				name: 'GoodsEdit',
				component: () => import('@/views/Goods/Edit.vue')
				
			},
			{
				path: 'category',
				name: 'GoodsCategory',
				component: () => import('@/views/Goods/Category.vue')
			},
			{
				path: 'release',
				name: 'GoodsRelease',
				component: () => import('@/views/Goods/Release.vue')
			}
		]
	},
	{
		path: '/user/',
		name: 'User',
		component: Layout,
		meta: { requiresAuth: true },
		children: [{
			path: 'info',
			name: 'UserInfo',
			component: () => import('@/views/User/Info.vue')
		},{
			path: 'list',
			name: 'UserList',
			component: () => import('@/views/User/List.vue')
		} ]
	},
	{
		path: '/auth/',
		name: 'Auth',
		component: Layout,
		meta: { requiresAuth: true },
		children: [{
				path: 'role',
				name: 'AuthRole',
				component: () => import('@/views/Auth/Role.vue')
			},
			{
				path: 'menu',
				name: 'AuthMenu',
				component: () => import('@/views/Auth/Menu.vue')
			}
		]
	},
	{
		path: '/order/',
		name: 'Order',
		component: Layout,
		meta: { requiresAuth: true },
		children: [{
			path: 'list',
			name: 'OrderList',
			component: () => import('@/views/Order/List.vue')
		}]
	}
]

const router = new VueRouter({
	routes
})

export default router
